home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows Expert
/
Windows Expert.iso
/
windownt
/
perlnt.zip
/
t
/
comp
/
arith.nt
next >
Wrap
Text File
|
1993-07-25
|
1KB
|
46 lines
print "1..14\n";
$hard_pi = 3.1415926535897932384626433;
# arc tangent of x/y
$pi = atan2(1, 1) * 4;
if ($hard_pi == $pi) {print "ok 1\n";} else {print "not ok 1\n";}
# sine
if (sin(0) == 0) {print "ok 2\n";} else {print "not ok 2\n";}
if (sin($pi/2) == 1) {print "ok 3\n";} else {print "not ok 3\n";}
# cosine
if (cos(0) == 1) {print "ok 4\n";} else {print "not ok 4\n";}
if (cos($pi) == -1) {print "ok 5\n";} else {print "not ok 5\n";}
# square root
if (sqrt(144) == 12) {print "ok 6\n";} else {print "not ok 6\n";}
# integer
if (int(123.456) == 123) {print "ok 7\n";} else {print "not ok 7\n";}
# natural log (log base e of x)
if (log(1) == 0) {print "ok 8\n";} else {print "not ok 8\n";}
$x = log(22026);
if ($x > 9.99 && $x < 10.1) {print "ok 9\n";} else {print "not ok 9\n";}
# exponent (e^x)
if (exp(0) == 1) {print "ok 10\n";} else {print "not ok 10\n";}
$x = exp(10);
if ($x > 22025.99 && $x < 22026.99)
{print "ok 11\n";} else {print "not ok 11\n";}
# seed the random number generator
srand (12345);
# now check some random numbers
$x = rand(1);
if ($x <= 1 && $x >= 0) {print "ok 12\n";} else {print "not ok 12\n";}
$x = rand(9);
if ($x <= 9 && $x >= 0) {print "ok 13\n";} else {print "not ok 13\n";}
$x = rand(9);
if ($x <= 9 && $x >= 0) {print "ok 14\n";} else {print "not ok 14\n";}